package org.openmrs.module.basicmodule.DSS.Interpreter.Function;

import org.openmrs.module.basicmodule.DSS.Interpreter.InterpreterVisitor;
import org.openmrs.module.basicmodule.DSS.ast.AST;
import org.openmrs.module.basicmodule.DSS.ast.AssignTree;
import org.openmrs.module.basicmodule.DSS.ast.BlockTree;
import org.openmrs.module.basicmodule.DSS.ast.FormalsTree;
import java.util.ArrayList;

/**
 *
 * @author Stephen
 */
public class Function {
    
    private FormalsTree formals;
    private BlockTree block;
    
    public Function() {}
    
    public Function(FormalsTree ft, BlockTree b) {
        this.formals = ft;
        this.block = b;
    }
    
    public Object execute(ArrayList args) {
        for (int i = 0; i < args.size(); i++) {
            AssignTree at = new AssignTree();
            at.addKid(formals.getKid(i+1));
            at.addKid((AST)args.get(i));
            at.accept(new InterpreterVisitor());
        }
        block.accept(new InterpreterVisitor());
        return null;
    }
}
